#include <iostream>

using namespace std;
const int N = 55;
int t, n, a, b, idx, nmax; 
int main(){
	cin >> t;
	while(t--){
		cin >> n;
		nmax = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if(a <= 10){
				if (b > nmax){
					nmax = b;
					idx = i + 1;
				}
			}
			
		}
		//cout << nmax << endl;
		cout << idx << endl;
	}

    return 0;
}


